package algotithm.leetcode.array.test1470;

/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/11-8:22
 * @URL https://leetcode-cn.com/problems/shuffle-the-array/
 * @Title 1470. 重新排列数组
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {2,5,1,3,4,7};
        int n = 3;
        int[] arr = solution.shuffle(nums,n);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    public int[] shuffle(int[] nums, int n) {
        int[] arr = new int[2* n];
        for (int i = 0; i < n; i++) {
            arr[i*2] = nums[i];
            arr[i*2 + 1] = nums[n + i];
        }
        return arr;
    }
}
